const mysql = require('mysql')

// 创建连接对象
const connnectionObject = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: 'admin123',
    port: '3306',
    database: 'myblog'
})

// 开始连接
connnectionObject.connect()

// 执行 SQL 语句
const sqlStatement = `insert into blogs(title,content,createtime,author) values ('标题C','内容C',1634607744531,'wangwu');`

// 查询
connnectionObject.query(sqlStatement, (err, result) => {
    if (err) {
        console.error(err)
        return
    }
    console.log(result)
})

// 关闭连接
connnectionObject.end()